using System;
using System.Collections.Generic;
using AllegNet;
using System.Text;

namespace DemonHunter
{
    /// <summary>
    /// levelBitmap index key: 
    ///     1-3 = skeleton run animation
    /// </summary>
    class Minotaur : Entity
    {
        //walk animation index
        private double currentAnimationIndex;

        private static List<Bmp> entityBitmaps;

        public Minotaur()
        {
            entityYLoc = 315;
            entityXLoc = Logic.GetInstance().GetXLoc() + 1024;

            killable = true;
        }

        public override void animate()
        {
            //update animation to play
            currentAnimationIndex += (.1 * speedModifier);
            //if the walk animation is out of bounds reset
            if ((int)currentAnimationIndex > entityBitmaps.Count - 1)
            {
                // if we are at this point, the minotaur has his axe down so see if it has hit player
                CheckPlayerHit();
                currentAnimationIndex = 0;
            }
        }

        private void CheckPlayerHit()
        {
            PlayerCharacter player = PlayerCharacter.GetInstance();
            if (entityXLoc > player.getEntityXLoc() && entityXLoc < player.getEntityXLoc() + player.GetCurrentBitmap().Width)
                player.ReduceHealth(10);
        }

        // don't allow minotaur to run right
        public override void moveRight()
        {       
        }

        // override DoXIncrease so that minotaur moves faster than other entities
        public override void DoXIncrease()
        {
            entityXLoc += 1 * speedModifier;
            // remove minotaur from game if he has run off the left side of the screen
            if (entityXLoc + entityBitmaps[0].Width <= Logic.GetInstance().GetXLoc()) Level.GetInstance().RemoveEntity(this);
        }

        public new static void LoadBitmaps()
        {
            entityBitmaps = new List<Bmp>();
            Game game = Game.GetInstance();
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\minotaur\\walk1mino.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\minotaur\\walk2mino.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\minotaur\\walk3mino.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\minotaur\\attack1Mino.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\minotaur\\attack2Mino.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\minotaur\\attack3Mino.bmp"));
        }

        public override Bmp GetCurrentBitmap()
        {
            return entityBitmaps[(int)currentAnimationIndex];
        }

        public override double GetCurrentBitmapHeight()
        {
            return entityBitmaps[(int)currentAnimationIndex].Height;
        }
    }
}
